package com.cwd.arm.infrastructure.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cwd.arm.infrastructure.dao.TargetConfirmAmountDao;
import com.cwd.arm.infrastructure.mapper.TargetConfirmAmountMapper;
import com.cwd.arm.infrastructure.po.TargetConfirmAmountPo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* Description:目标确认金额
* Created on 2022年01月15日
* @author  yan
*/
@Service
public class TargetConfirmAmountDaoImpl extends ServiceImpl<TargetConfirmAmountMapper, TargetConfirmAmountPo> implements TargetConfirmAmountDao {

    @Override
    public void delByProjectId(Long projectId,int year) {
        QueryWrapper<TargetConfirmAmountPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("project_id",projectId);
        queryWrapper.eq("year",year);
        baseMapper.delete(queryWrapper);
    }

    @Override
    public List<TargetConfirmAmountPo> selectByProjectId(Long projectId) {
        QueryWrapper<TargetConfirmAmountPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("project_id",projectId);
        return list(queryWrapper);
    }

    @Override
    public TargetConfirmAmountPo selectByProjectYear(Long projectId, int year) {
        QueryWrapper<TargetConfirmAmountPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("project_id",projectId);
        queryWrapper.eq("year",year);
        return getOne(queryWrapper);
    }
}
